<?php

// Namespace

namespace Loop;


/**
 * CException is a child class of the basic Exception class.
 * It exists because in Loop exceptions have a name/ID rather than a code
 * So this class forces Exception to have a code that returns an ID
 * Exception constructor is also extremely weird, so it's a chance to fix that odd behaviour
 *
 * @package		Loop
 * @category	Core
 */

class CException extends \Exception
{
	// Properties
	
	protected $code = null;
	protected $context = null;
	
	
	/**
	 * @param	string	$exceptionCode		The ID/name of the exception
	 * @param	array	$exceptionContext	An associative array that contains anything related to the context
	 */
	
	public function __construct($exceptionCode, $exceptionContext = null)
	{
		$this->code = $exceptionCode;
		$this->context = $exceptionContext;
	}
	
	
	/**
	 * Gets the context of the exception
	 *
	 * @return	array	An array with all contextual data
	 */
	
	public function getContext()
	{
		return $this->context;
	}
}

?>
